package com.zyong.design.pattern.mediator.case1;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: zyong-design-pattern
 * @ClassName: ConcreteMediator
 * @author: zyong
 * @create: 2024-03-31 23:48
 */
public class ConcreteMediator implements Mediator {
    private List<Colleague> colleagues = new ArrayList<>();

    @Override
    public void register(Colleague colleague) {
        colleagues.add(colleague);
    }

    @Override
    public void relay(Colleague colleague, String message) {
        for (Colleague c : colleagues) {
            if (c != colleague) {
                c.receive(message);
            }
        }
    }
}
